package com.cyy.cn.controller;


import com.cyy.cn.pojo.Comment;
import com.cyy.cn.service.CommentService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * spit控制器层
 * @author Administrator
 *
 */
@RestController
@CrossOrigin
@RequestMapping("/comment")
public class CommentController {

	@Autowired
	private CommentService commentService;

	@RequestMapping(value = "/add",method = RequestMethod.POST)
	public Result save(@RequestBody Comment comment){
		 commentService.add(comment);
		 return new Result(true,StatusCode.OK,"提交成功");
	}

	@RequestMapping(value="/article/{articleid}",method = RequestMethod.GET)
	public Result findByActicleid(@PathVariable String articleid){
	     return new Result(true,StatusCode.OK,"查询成功",commentService.findByArticleid(articleid));
    }
}
